package com.aisile.article.controller;

import com.aisile.api.article.ApAuthorControllerApi;
import com.aisile.article.service.ApAuthorService;
import com.aisile.model.article.pojos.ApAuthor;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Auther:yry
 * @Date:2024/7/19 0019
 * @VERSON:1.0
 */
@RestController
@RequestMapping("/api/v1/apauthor")
public class ApAuthorController implements ApAuthorControllerApi {

    @Autowired
    private ApAuthorService apAuthorService;


    @GetMapping("/getby_userid")  //  ?id=4
    @Override
    public ApAuthor findByUserId(@RequestParam("id") Integer id) {
        return apAuthorService.getOne(Wrappers.<ApAuthor>lambdaQuery().eq(ApAuthor::getUserId, id));
    }

    @PostMapping("/save")
    @Override
    public ApAuthor save(@RequestBody ApAuthor apAuthor) {
        apAuthorService.save(apAuthor);
        return apAuthor;
    }
}
